from django.shortcuts import render_to_response, get_object_or_404
from races.models import Race, Leg
from race_stats.mobile import mobile_browser


#
#
#
def index(request):
    race_list = Race.objects.all().order_by('start_date')
    if mobile_browser:
        template = 'races/m_index.html'
    else:
        template = 'races/index.html'
    return render_to_response(template, {'race_list': race_list})


#
#
#
def detail(request, race_id):
    race = get_object_or_404(Race, pk=race_id)
    if mobile_browser:
        template = 'races/m_detail.html'
    else:
        template = 'races/detail.html'
    return render_to_response(template, {'race': race})

